import csv


def read_txt(filepath):
    with open(filepath, "r+", encoding='utf-8') as f:
        dates = f.readlines()
    return dates

def write_txt(filepath,text):
    with open(filepath, "a", encoding='utf-8') as f:
        f.write(text)
        f.write('\n')

def read_csv(filepath):
    f = open(filepath, 'r+', encoding='utf-8')
    data = list(csv.reader(f))
    f.close()
    return data

class ReadExcel():
    def __init__(self):
        pass

    def read_excel(filepath, openpyxl=None):
        wb = openpyxl.load_workbook('excelxxx.xlsx')
        print(wb.sheetnames)  # 查看Excel文件中的sheet的名字
        test = wb["test"]  # 根据名字获取sheet
        xxx = wb.worksheets[1]  # 根据索引获取sheet
        # row_num = xxx.max_row #返回sheet中行数的最大值
        # print(row_num)
        # for i in range(1,row_num):#必须从1开始，因为cell是默认从1开始的，相当于数学中的坐标
        #     print(xxx.cell(i,1).value)
        # row_num = test.max_row
        # print(row_num)
        # for i in range(2,row_num+1):
        #     print(test.cell(i,1).value)
        for i in xxx['A1':'A10']:
            print(i)
